<?php

        class SqlHelper{
        	private $conn;
        	private $host="localhost";
        	private $user="root";
        	private $password="root";
        	private $db="wxCatering";
        	
        	function SqlHelper(){
        		
        		$this->conn=mysql_connect($this->host,$this->user,$this->password);
        		if(!$this->conn){
        			die("连接失败".mysql_error());
        		}
        		mysql_select_db($this->db,$this->conn);
        		mysql_query("set names utf8");
        	}
        	//对dql语句的执行
        	public function execute_dql($sql){
        		  $res=mysql_query($sql,$this->conn) or die(mysql_errno());
        		  return $res;
        	}
        	//对dml语句的执行
        	public function execute_dml($sql){
        		$b=mysql_query($sql,$this->conn);
        		if(!$b){
        			return 0;       //失败
        		}else{
        			if(mysql_affected_rows($this->conn)){
        				return 1;  //成功
        			}else{
        				return 2;   //没有行数受到影响
        			}
        		}
        	}
        
        }

?>